# Copyright 2017 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

LOCAL_DIR := $(GET_LOCAL_DIR)

MODULE := $(LOCAL_DIR).ps

MODULE_TYPE := userapp
MODULE_GROUP := core

MODULE_SRCS += \
    $(LOCAL_DIR)/ps.c

MODULE_NAME := ps

MODULE_LIBS := \
    system/ulib/fdio \
    system/ulib/zircon \
    system/ulib/c

MODULE_STATIC_LIBS := \
    system/ulib/pretty \
    system/ulib/task-utils

include make/module.mk


MODULE := $(LOCAL_DIR).top

MODULE_TYPE := userapp
MODULE_GROUP := core

MODULE_SRCS += $(LOCAL_DIR)/top.c

MODULE_NAME := top

MODULE_LIBS := \
    system/ulib/fdio \
    system/ulib/zircon \
    system/ulib/c

MODULE_STATIC_LIBS := \
    system/ulib/pretty \
    system/ulib/task-utils

include make/module.mk


MODULE := $(LOCAL_DIR).kill

MODULE_TYPE := userapp
MODULE_GROUP := core

MODULE_SRCS += $(LOCAL_DIR)/kill.c

MODULE_NAME := kill

MODULE_LIBS := \
    system/ulib/fdio \
    system/ulib/zircon \
    system/ulib/c

MODULE_STATIC_LIBS := \
    system/ulib/task-utils

include make/module.mk


MODULE := $(LOCAL_DIR).killall

MODULE_TYPE := userapp
MODULE_GROUP := core

MODULE_SRCS += $(LOCAL_DIR)/killall.c

MODULE_NAME := killall

MODULE_LIBS := \
    system/ulib/fdio \
    system/ulib/zircon \
    system/ulib/c

MODULE_STATIC_LIBS := \
    system/ulib/task-utils

include make/module.mk


MODULE := $(LOCAL_DIR).vmaps

MODULE_TYPE := userapp
MODULE_GROUP := core

MODULE_SRCS += $(LOCAL_DIR)/vmaps.c

MODULE_NAME := vmaps

MODULE_LIBS := \
    system/ulib/fdio \
    system/ulib/zircon \
    system/ulib/c

MODULE_STATIC_LIBS := \
    system/ulib/pretty \
    system/ulib/task-utils

include make/module.mk


MODULE := $(LOCAL_DIR).vmos

MODULE_TYPE := userapp
MODULE_GROUP := core

MODULE_SRCS += \
    $(LOCAL_DIR)/vmos.cpp \
    $(LOCAL_DIR)/vmo-utils.c

MODULE_NAME := vmos

MODULE_LIBS := \
    system/ulib/fdio \
    system/ulib/zircon \
    system/ulib/c

MODULE_STATIC_LIBS := \
    system/ulib/pretty \
    system/ulib/task-utils

include make/module.mk


MODULE := $(LOCAL_DIR).memgraph

MODULE_TYPE := userapp
MODULE_GROUP := core

MODULE_SRCS += \
    $(LOCAL_DIR)/memgraph.cpp \
    $(LOCAL_DIR)/resources.c \
    $(LOCAL_DIR)/vmo-utils.c

MODULE_NAME := memgraph

MODULE_LIBS := \
    system/ulib/fdio \
    system/ulib/zircon \
    system/ulib/c

MODULE_STATIC_LIBS := \
    system/ulib/zxcpp \
    system/ulib/task-utils

# Generate an include file that contains the schema json

# See MODULE_BUILDDIR in module.mk
LOCAL_BUILDDIR := $(call TOBUILDDIR,$(MODULE))

LOCAL_SCHEMA_HEADER := $(LOCAL_BUILDDIR)/include/memgraph-schema.h

MODULE_CPPFLAGS := -I$(LOCAL_BUILDDIR)/include

MODULE_SRCDEPS := $(LOCAL_SCHEMA_HEADER)

$(LOCAL_SCHEMA_HEADER): $(LOCAL_DIR)/memgraph-schema.json
	@$(MKDIR)
	$(call BUILDECHO,generating $@)
	$(NOECHO)( \
	   echo '// DO NOT EDIT THIS FILE' && \
	   echo "// Generated from $^" && \
	   echo '#pragma once' && \
	   echo 'static const char kMemgraphSchema[] = R":JSON:(' && \
	   cat $^ && \
	   echo '):JSON:";' ) > $@

# Clean up our temporary vars.
LOCAL_BUILDDIR :=
LOCAL_SCHEMA_HEADER :=

include make/module.mk


MODULE := $(LOCAL_DIR).kstats

MODULE_TYPE := userapp

MODULE_SRCS += \
    $(LOCAL_DIR)/kstats.c \
    $(LOCAL_DIR)/resources.c

MODULE_NAME := kstats
MODULE_GROUP := core

MODULE_LIBS := \
    system/ulib/fdio \
    system/ulib/zircon \
    system/ulib/c

MODULE_STATIC_LIBS := \
    system/ulib/pretty

include make/module.mk


MODULE := $(LOCAL_DIR).threads

MODULE_TYPE := userapp

MODULE_SRCS += \
    $(LOCAL_DIR)/threads.cpp

MODULE_NAME := threads
MODULE_GROUP := core

MODULE_LIBS := \
    third_party/ulib/backtrace \
    third_party/ulib/ngunwind \
    system/ulib/fdio \
    system/ulib/zircon \
    system/ulib/c

MODULE_STATIC_LIBS := \
    system/ulib/inspector \
    system/ulib/pretty \
    system/ulib/fbl \
    system/ulib/zxcpp \
    system/ulib/task-utils \

include make/module.mk
